package com.chengzhi.controller;

import com.chengzhi.service.ServiceTwoApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ruanchengzhi
 * @description: test
 * @date 2019/9/25 19:58
 */
@RestController
public class TestController {

    @Autowired
    private DiscoveryClient discoveryClient;

    @Autowired
    private ServiceTwoApi serviceTwoApi;

    @GetMapping("/hello")
    public void hello() {
        System.out.println(serviceTwoApi.hello());
    }

    @GetMapping("client")
    public void client() {
        System.out.println("client");
    }

    @GetMapping("/services")
    public Object services() {
        return discoveryClient.getServices();
    }

    @GetMapping("/service")
    public Object service() {
        return discoveryClient.getInstances("service-one");
    }
}
